package com.fc.captcha.autoconfigure;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 验证码自动配置类
 */
@Configuration
@EnableConfigurationProperties(com.fc.captcha.autoconfigure.CaptchaProperties.class)
@ConditionalOnClass(name = "cn.hutool.captcha.CaptchaUtil")
@ConditionalOnProperty(prefix = "captcha", value = "enabled", havingValue = "true", matchIfMissing = true)
public class CaptchaAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public CaptchaService captchaService(com.fc.captcha.autoconfigure.CaptchaProperties properties) {
        return new CaptchaService(properties);
    }
}